﻿Shader "Kun URP/Test"
{
    Properties
    {
        [KunMain(Group, _, true)] _Group ("Group", Float) = 1
        [KunSub(Group)]_MainTex ("Texture1", 2D) = "white" {}
        [KunToggle(Group, _Test_Sub_Group)]_Test1 ("Test1", Float) = 1
        [KunSub(Group)]_Test2 ("Test2", Color) = (1, 1, 1, 1)
        // [KunSpace(,10)]
        [KunSub(_Test_Sub_Group)]_Test3 ("Test3", Color) = (1, 1, 1, 1)
        [KunHeader(, Test a Header)]
        [KunSub(Group)][PowerSlider(2.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.08
        [KunEnum(Group, UnityEngine.Rendering.BlendMode)] _Blend2 ("Blend mode subset", Float) = 1
        [KunEnum(Group, One,1)] _Blend3 ("Blend mode 3", Float) = 1
        // [Space(10)]
        // [Header(Test Head)]
        _TestTex ("Texture2", 2D) = "white" {}
        [Enum(UnityEngine.Rendering.BlendMode)] _Blend ("Blend mode", Float) = 1

        
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog
            #pragma shader_feature_local _Test_Sub_Group

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                // sample the texture
                fixed4 col = tex2D(_MainTex, i.uv);
                // apply fog
                UNITY_APPLY_FOG(i.fogCoord, col);
                #ifdef _Test_Sub_Group
                    return float4(1.0, 1.0, 1.0, 1.0);
                #endif
                return float4(0.0, 0.0, 0.0, 1.0);
            }
            ENDCG
        }
    }
    CustomEditor "KunRenderPipeline.Editor.KunShaderGUI"
}
